<?php
	class Model_home extends CI_Model{
		protected $_questions = "tbl_questions";
		protected $_category = "tbl_category";
		protected $_categorie = "tbl_categorie";
		public function __construct(){
			parent::__construct();
			$this->load->database();
		}
		public function newquest($limit){
			$this->db->join("tbl_user","tbl_user.user_id = tbl_questions.userid");
			$this->db->order_by("id","desc");
			$this->db->limit($limit);
			return $this->db->get($this->_questions)->result_array();
		}
		public function listall($cateid){
			$this->db->where("cid",$cateid);
			return $this->db->get($this->_category)->row_array();
		}
		public function getcates($cateid){
			$this->db->where("cateid",$cateid);
			return $this->db->get($this->_categorie)->result_array();
		}
		public function getquest($cateid,$limit){
			$this->db->join("tbl_user","tbl_user.user_id = tbl_questions.userid");
			$this->db->where("cateid",$cateid);
			$this->db->limit($limit);
			return $this->db->get($this->_questions)->result_array();
		}
	}